//
//  BaseScrollView.swift
//  TimeBoat
//
//  Created by bo wang on 2022/8/31.
//  Copyright © 2022 Time Boat. All rights reserved.
//

import Foundation

@objc class BaseScrollView: UIScrollView {
    @IBOutlet weak var topInsetReferView: UIView?
    @IBOutlet weak var bottomInsetReferView: UIView?
    override func layoutSubviews() {
        super.layoutSubviews()
        if let view = topInsetReferView {
            contentInset.top = view.bounds.height
        }
        if let view = bottomInsetReferView {
            contentInset.bottom = view.bounds.height
        }
    }
}

@objc class BaseTableView: UITableView {
    @IBOutlet weak var topInsetReferView: UIView?
    @IBOutlet weak var bottomInsetReferView: UIView?
    override func layoutSubviews() {
        super.layoutSubviews()
        if let view = topInsetReferView {
            contentInset.top = view.bounds.height
        }
        if let view = bottomInsetReferView {
            contentInset.bottom = view.bounds.height
        }
    }
}

@objc class BaseCollectionView: UICollectionView {
    @IBOutlet weak var topInsetReferView: UIView?
    @IBOutlet weak var bottomInsetReferView: UIView?
    override func layoutSubviews() {
        super.layoutSubviews()
        if let view = topInsetReferView {
            contentInset.top = view.bounds.height
        }
        if let view = bottomInsetReferView {
            contentInset.bottom = view.bounds.height
        }
    }
}
